/**
 * intramap 3d 테스트
 * 필요 함수 모음 
 * 2014.05.20
 * 이명환 
 */


/******************************************************************************/
function getInput() {
	/*input & text*/
	//itf
	var terrainLayerInput = 'itf 이름: <input type="text" id="layerTName" size="6" value="'+terrainLayer+'">';
	var terrainURLInput = 'URL 주소: <input type="text" id="terrainURL" size="40" value="'+terrainURL+'">';
	//grid
	var gridLayerInput = 'grid 이름: <input type="text" id="layerGName" size="5" value="'+gridLayer+'">';
	var gridURLInput = 'URL 주소: <input type="text" id="gridURL" size="40" value="'+gridURL+'">';
	var gridMaxdistInput = '가시거리: <input type="text" id="maxdist" size="2" value="3000">';
	var gridRscPathInput = 'Model 경로: <input type="text" id="rscPath" size="6" value="">';
	
	
	/*button*/
	var menuItf = '<input type="button" id="layer2" value="itf" onclick="javascript:loadTerrain();">';
	var menuGrid = '<input type="button" id="grid" value="grid" onclick="javascript:loadGrid();">';
	
	inputDiv = "";
//	if( !terrainLoad ){
		inputDiv = terrainLayerInput+' / ';
		inputDiv += terrainURLInput+' / ';
		inputDiv += menuItf+'<br/>';
//	}
	
	if(pageType!="terrain"){
		inputDiv += gridLayerInput+' / ';
		inputDiv += gridURLInput+' / ';
		inputDiv += gridMaxdistInput+' / ';
		inputDiv += gridRscPathInput+' / ';
		inputDiv += menuGrid;
		if(pageType=="grid"){
		}else if(pageType=="Texture"){
		}else if(pageType=="scene"){
		}else if(pageType=="build"){
		}else if(pageType=="road"){
		}else if(pageType=="garo"){	
		}else if(pageType=="brush"){
		}else if(pageType=="bound"){
		}else if(pageType=="distance"){
		}else if(pageType=="prospect"){
		}else if(pageType=="sunlight"){
		}else if(pageType=="slope"){
		}else if(pageType=="flood"){
		}else if(pageType=="height"){
		}
	}
	

	$("#divInput").html(inputDiv);//페이지 상단 세팅
}

function getTopMenu() {
//	alert("getTopMenu: "+showTypeArr.toString());
	var ragoTerrain = '지도 모드: <input type="button" id="road" value="주간 모드" onclick="javascript:lightModeCont(\'terrain\');">'+' / ';

	if( 0 < showTypeArr.length ){
		var menuLayerShow = '레이어 숨기기: ';
		
		menuLayerShow += '<select id="LayerShowSel">';
		for(var i=0; i<showTypeArr.length; i++){
			menuLayerShow += '<option value="'+showTypeArr[i]+'"';
			if( i == showN ){
				menuLayerShow += 'selected';
			}
			menuLayerShow += '>'+showTypeArr[i][0]+'의 '+showTypeArr[i][1]+'</option>';
		}
		menuLayerShow += '</select>';

		menuLayerShow += ' <input type="button" id="layerShowBt" value="on/off" onclick="javascript:layerShowControl();">'+' / ';
	}else{
		var menuLayerShow = "";
	}

	var menuReload = '새로고침: <input type="button" id="page reload" value="F5 새로고침" onclick="javascript:reload();">';
	
	topMenu = ragoTerrain;
//	topMenu += ragoNight;
	topMenu += menuLayerShow;
	topMenu += menuReload;	

	$("#divTopMenu").html(topMenu);	
}

function getSubMenu() {
	/******************************input, button 세팅************************************************/
	//shp
	var shpLayerInput = 'shp 이름: <input type="text" id="layerTTName" size="7" value="'+shpLayer+'">';
	var shpURLInput = 'URL 주소: <input type="text" id="textureURL" size="60" value="'+shpURL+'">';
	var shpModeSelect = '표시 모드: <select id="shpMode"><option value="Both" selected>면과 외곽선</option><option value="Polygon">면</option><option value="Outline">외곽선</option></select>';
	//scene
	var sceneLayerInput = '3DS 이름: <input type="text" id="layerSName" size="7" value="'+sceneLayer+'">';
	var sceneURLInput = 'URL 주소: <input type="text" id="sceneURL" size="60" value="'+sceneURL+'">';
	var scenePosionSelect = '위치: <select id="scenePosion"><option value="Scene" selected>기본</option><option value="SingleCenter">중앙</option>';
	//build
	var buildNumFloorInput = '층 수: <input type="text" id="buildNumFloor" size="3" value="25">';
	var buildFloorHeightInput = '층간 높이: <input type="text" id="buildFloorHeight" size="3" value="1.5">';
	var buildTexInput = 'tex: <input type="text" id="buildTex" size="3" value="">';
	//road roadMatID+"^"+roadNumline+"^"+roadCenterline+"^"+roadWidth+"^"+roadTileheight+"^"+roadHeight;
	var roadMatIDInput = 'matID: <input type="text" id="roadMatID" size="3" value="0">';
	var roadNumlineInput = 'numline: <input type="text" id="roadNumline" size="3" value="2">';
	var roadCenterlineInput = 'centerline: <input type="text" id="roadCenterline" size="3" value="11">';
	var roadWidthInput = 'width: <input type="text" id="roadWidth" size="3" value="23">';
	var roadTileheightInput = 'tileheight: <input type="text" id="roadTileheight" size="3" value="3">';
	var roadHeightInput = 'height: <input type="text" id="roadHeight" size="3" value="22">';
	//garo lightx = 40; lighty = 40; lightz = 40; theta = 30; modelpath = "";	
	var garoLightxInput = 'Lightx: <input type="text" id="garoLightx" size="3" value="40">';
	var garoLightyInput = 'Lighty:<input type="text" id="garoLighty" size="3" value="40">';
	var garoLightzInput = 'Light:<input type="text" id="garoLightz" size="3" value="40">';
	var garoThetaInput = 'Theta: <input type="text" id="garoTheta" size="3" value="30">';
	var garoModelpathInput = 'Modelpath: <input type="text" id="garoModelpath" size="10" value="">';
	//brush
	var brushAreaModeInput = 'AreaMode: <select id="brushAreaMode" name="brushAreaMode"><option value="Circle">원</option><option value="Rect">사각</option></select>';
	var brushAmountInput = 'Amount:<input type="text" id="brushAmount" size="5" value="100">';
	var brushRadiusInput = 'Radius: <input type="text" id="brushRadius" size="5" value="1000">';
	//sunlight
	var sDateInput = '<input type="text" id="sYe" size="2" value="2014">년<input type="text" id="sMo" size="2" value="5">월<input type="text" id="sDa" size="2" value="01">일 <input type="text" id="sHo" size="2" value="8">시<input type="text" id="sMi" size="2" value="01">분';
	var eDateInput = '<input type="text" id="eHo" size="2" value="19">시<input type="text" id="eMi" size="2" value="59">분';
	var sunlighModeSelect = '모드: <select id="sunlighMode"><option value="Caster" selected>기본</option><option value="Receiver">피해 분석</option></select>';
	var sunlighSpeedInput = '분석속도: <input type="text" id="sunlighSpeed" size="2" value="200">';
	//flood
	var floodSpeedInput = '분석속도: <input type="text" id="floodSpeed" size="2" value="20">';
	var floodHeightInput = '높이: <input type="text" id="floodHeight" size="2" value="60">';
	//height
	var heightInput = '분석 높이: <input type="text" id="height" size="2" value="100">';
	/******************************************************************************/


	var menuShp = '<input type="button" id="Texture" value="Texture" onclick="javascript:loadTexture();">';

	var menuScene='<input type="button" id="3ds" value="3ds view" onclick="javascript:loadScene();">';

	var menuBuild = '<input type="button" id="build" value="build" onclick="javascript:geometryBuild();">';

	var menuRoad = '<input type="button" id="road" value="road" onclick="javascript:geometryRoad();">';

	var menuGaro = '<input type="button" id="road" value="garo" onclick="javascript:geometryGaro();">';

	var menuBrush = '<input type="button" id="brush" value="brush" onclick="javascript:geometryBrush();">';

	var menuBoundT = '<input type="button" id="boundT" value="bound" onclick="javascript:geometryBound();">';
	var menuBoundF = '<input type="button" id="boundF" value="clear" onclick="javascript:endComm();">';

	var menuDistance = '<input type="button" id="distance" value="distance view" onclick="javascript:web3DDistance();">';
	var menuDistanceEnd = '<input type="button" id="distanceEnd" value="distance end" onclick="javascript:endComm();">';

	var menuProspect = '<input type="button" id="prospect view" value="prospective view" onclick="javascript:web3DProspect();">';
	var menuProspectEnd = '<input type="button" id="prospect view" value="prospective end" onclick="javascript:endComm();">';

	var menuSunlightMode= '<input type="button" id="sunlight set" value="sunlight mode" onclick="javascript:web3DSunlight();">';
	var menuSunlight= '<input type="button" id="sunlight" value="sunlight view" onclick="javascript:sunlightStart();">';
	var menuSunlightEnd = '<input type="button" id="sunlight end" value="sunlight end" onclick="javascript:endComm();">';

	var menuSlope='<input type="button" id="slope" value="slope view" onclick="javascript:web3DSlope();">';
	var menuSlopeEnd='<input type="button" id="slope end" value="slope end" onclick="javascript:endComm();">';

	var menuFlood='<input type="button" id="flood" value="flood view" onclick="javascript:web3DFlood();">';
	var menuFloodEnd='<input type="button" id="flood end" value="flood end" onclick="javascript:endComm();">';

	var menuHeight='<input type="button" id="height" value="height view" onclick="javascript:web3DHeight();">';
	var menuHeightEnd='<input type="button" id="height end" value="height end" onclick="javascript:endComm();">';
	
	subMenu = "";
	if(pageType!="terrain"){
		if(pageType=="grid"){
		}else if(pageType=="Texture"){
			subMenu += shpLayerInput+' / ';
			subMenu += shpURLInput+' / ';
			subMenu += shpModeSelect+' / ';
			subMenu += menuShp;
		}else if(pageType=="scene"){
			subMenu += sceneLayerInput+' / ';
			subMenu += sceneURLInput+' / ';
			subMenu += scenePosionSelect+' / ';
			subMenu += menuScene;
		}else if(pageType=="build"){
			subMenu += buildNumFloorInput+' / ';	
			subMenu += buildFloorHeightInput+' / ';
			subMenu += buildTexInput+' / ';
			subMenu += menuBuild;
		}else if(pageType=="road"){
			subMenu += roadMatIDInput+' / ';
			subMenu += roadNumlineInput+' / ';
			subMenu += roadWidthInput+' / ';
			subMenu += roadTileheightInput+' / ';
			subMenu += roadHeightInput+' / ';
			subMenu += roadCenterlineInput+' / ';
			subMenu += menuRoad;
		}else if(pageType=="garo"){	
			subMenu += garoLightxInput+' / ';
			subMenu += garoLightyInput+' / ';
			subMenu += garoLightzInput+' / ';
			subMenu += garoThetaInput+' / ';
			subMenu += garoModelpathInput+' / ';			
			subMenu += menuGaro;
		}else if(pageType=="brush"){
			subMenu += brushAreaModeInput+' / ';
			subMenu += brushAmountInput+' / ';
			subMenu += brushRadiusInput+' / ';
			subMenu += menuBrush;
		}else if(pageType=="bound"){
			subMenu += menuBoundT+' / ';
			subMenu += menuBoundF;
		}else if(pageType=="distance"){
			subMenu += menuDistance;
			subMenu += menuDistanceEnd;
		}else if(pageType=="prospect"){
			subMenu += menuProspect;
			subMenu += menuProspectEnd;
		}else if(pageType=="sunlight"){
			subMenu += sDateInput+' ~ ';
			subMenu += eDateInput+' / ';
			subMenu += sunlighModeSelect+' / ';
			subMenu += sunlighSpeedInput+' / ';
			subMenu += menuSunlightMode;
			subMenu += '<br/>'+menuSunlight;
			subMenu += menuSunlightEnd;
		}else if(pageType=="slope"){
			subMenu += menuSlope;
			subMenu += menuSlopeEnd;
		}else if(pageType=="flood"){
			subMenu += floodSpeedInput+' / ';
			subMenu += floodHeightInput+' / ';
			subMenu += menuFlood;
			subMenu += menuFloodEnd;
		}else if(pageType=="height"){
			subMenu += heightInput+' / ';
			subMenu += menuHeight;
			subMenu += menuHeightEnd;
		}
	}
	

	$("#divSubMenu").html(subMenu);	
}

/******************************************************************************/
function getLeftMenu(){
	leftMenu = '';
	leftMenu += '<h4>1. 가시화 데이터 연동 방법</h4>';
	leftMenu += '<h5>1.1. 지형연동 방법</h5>';
	leftMenu += '<ul>';
	/*if( terrainLoad ){
		leftMenu += '<li><a class="list"><s><em>1.1.1. 지형 데이터(itf) 올리기 완료</em></s></a></li>';
	}else{
		leftMenu += '<li><a class="link" onclick="Init(\'terrain\', true);">1.1.1. 지형 데이터(itf) 올리기</a></li>';
	}*/
	leftMenu += '<li><a class="link" onclick="Init(\'terrain\', true);">1.1.1. 지형 데이터(itf) 올리기</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'grid\', true);">1.1.2. 지형 데이터(grid) 올리기</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'Texture\', true);">1.2.1. shp 파일 텍스처레이어 연동</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'scene\', true);">1.2.3. 3ds 모델 불러오기(샘플)</a></li>';
	leftMenu += '</ul>';
	leftMenu += '<h5>1.2.4. 마우스이벤트와 그리기<br/> 유형 함수를 통하여 그리기</h5>';
	leftMenu += '<ul>';
	leftMenu += '<li><a class="link" onclick="Init(\'build\', true);">1.2.4.1. 건물 그리기</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'road\', true);">1.2.4.2. 도로 그리기</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'garo\', true);">1.2.4.3. 가로등 그리기</a></li>';
	leftMenu += '</ul>';
	leftMenu += '<h5>1.2.5. 지형 편집</h5>';
	leftMenu += '<ul>';
	leftMenu += '<li><a class="link" onclick="Init(\'brush\', true);">1.2.5.1. 지형 높낮이 조절</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'bound\', true);">1.2.5.2. 지형 평탄화</a></li>';
	leftMenu += '</ul>';
	leftMenu += '<h4>2. IntraMap 3D web 분석기능</h4>';;
	leftMenu += '<ul>';
	leftMenu += '<li><a class="link" onclick="Init(\'distance\', true);">2.1. 가시권 분석</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'prospect\', true);">2.2. 조망권 분석</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'sunlight\', true);">2.3. 일조권 분석</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'slope\', true);">2.4. 평균경사도 분석</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'flood\', true);">2.5. 침수 분석</a></li>';
	leftMenu += '<li><a class="link" onclick="Init(\'height\', true);">2.6. 고도 분석</a></li>';
	leftMenu += '<li><a class="list">2.7. 적정분석</a></li>';
	leftMenu += '</ul>';
	leftMenu += '<h4>3. 추가 기능</h4>';;
	leftMenu += '<ul>';
	leftMenu += '<li><a class="link" href="/intraweb/intraMap3D/test_dx.html" target="_new">3.1. 추가 기능</a></li>';
	leftMenu += '</ul>';
	

	$("#leftMenu").html(leftMenu);//페이지 메뉴 세팅
}
/******************************************************************************/

/*
 * 현재는 terrain 과 mouse 안에서만 컨트롤 중
 */
function pageCommControl(mode, value){//페이지 정보 값
	var msg = "";
/*	if( mode == "terrain" ){
		msg = "Load: ";
		msg += value+"</br>";
		
		title="지형 테이터(itf)올리기 완료";
		
//		Init(pageType);//
		
		$("#pageCommTerrain").html(msg);//페이지 상태 장 세팅
	}*/
	if( mode == "mouse" ){
		msg = "MouseMode: "+value;
		
		$("#pageCommMouse").html(msg);//페이지 상태 장 세팅
	}
}
